package com.asiainfo.framework.boot;

import com.asiainfo.framework.annotation.ExcludeAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;

import static com.asiainfo.common.constants.Constants.PROJECT_BASE_PACKAGE;


@ComponentScan(
        value = PROJECT_BASE_PACKAGE,
        excludeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM, value = {CustomConfigurationExcludeFilter.class})}
)
@ExcludeAutoConfiguration({
        DataSourceAutoConfiguration.class,
        TransactionAutoConfiguration.class,
})
public abstract class BaseSpringBootServletInitializer extends SpringBootServletInitializer {

    protected static void run(Class<?> clz, String[] args) {
        SpringApplication.run(clz, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(this.getClass());
    }

}
